package cn.lan.generator.factory;

import cn.lan.generator.manager.DB2ProjectManager;
import cn.lan.generator.manager.MySQLProjectManager;
import cn.lan.generator.manager.AbstractProjectManager;
import cn.lan.generator.manager.SQLServerProjectManager;
import cn.lan.generator.utils.Constant;

import javax.xml.bind.ValidationException;

/**
 * 创建项目
 *
 * @author lanping
 * @version 1.0
 * @date 2019-06-30
 **/
public class ProjectManagerFactory {

    public static AbstractProjectManager getProjectManager(String dbType) throws ValidationException {
        AbstractProjectManager projectManager = null;
        if (Constant.DB_TYPE_MYSQL.equals(dbType)) {
            projectManager = new MySQLProjectManager();
        }else if (Constant.DB_TYPE_DB2.equals(dbType)) {
            projectManager = new DB2ProjectManager();
        } else if (Constant.DB_TYPE_SQLSERVER.equals(dbType)) {
            projectManager = new SQLServerProjectManager();
        }else{
            throw new ValidationException("数据库类型 dbType 参数错误");
        }
        return projectManager;
    }

}
